package com.oa.srms.apps.business.student.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.oa.srms.apps.business.student.IFamilyInfoService;
import com.oa.srms.apps.dao.student.IFamilyInfoDao;
import com.oa.srms.apps.entity.student.FamilyInfoValue;

public class FamilyInfoServiceImpl implements IFamilyInfoService {
	@Autowired
	private FamilyInfoValue familyInfoValue;
	@Autowired
	private IFamilyInfoDao familyInfoDao;
	@Override
	public Integer addFamilyInfo(String fatherName, String fatherTel,
			String motherName, String motherTel, String address)
			throws Exception {
		familyInfoValue.setFatherName(fatherName);
		familyInfoValue.setFatherTel(fatherTel);
		familyInfoValue.setMotherName(motherName);
		familyInfoValue.setMotherTel(motherTel);
		familyInfoValue.setAddress(address);
		return familyInfoDao.addFamilyInfo(familyInfoValue);
	}

	@Override
	public void modifyFamilyInfo(Integer id, String fatherName,
			String fatherTel, String motherName, String motherTel,
			String address) throws Exception {
		familyInfoValue=this.queryById(id);
		if(familyInfoValue!=null){
			familyInfoValue.setFatherName(fatherName);
			familyInfoValue.setFatherTel(fatherTel);
			familyInfoValue.setMotherName(motherName);
			familyInfoValue.setMotherTel(motherTel);
			familyInfoValue.setAddress(address);
			familyInfoDao.editFamilyInfo(familyInfoValue);
		}

	}

	@Override
	public FamilyInfoValue queryById(Integer id) throws Exception {
		return familyInfoDao.queryById(id);
	}

	@Override
	public List<FamilyInfoValue> queryFamilyInfo() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
